package com.task.controller;

import com.alibaba.fastjson.JSONObject;
import com.basemodel.Result;
import com.task.model.ResultModel;
import com.task.service.DownloadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: cxt
 * @time: 2023/4/5
 * 多线程下载
 */
@RestController
@RequestMapping("/download")
public class DownloadController {

    @Autowired
    private DownloadService downloadService;

    /**
     * 异步去下载
     */
    @GetMapping("/get")
    public void download(@RequestParam String filePath) {
        downloadService.download(filePath, true, "D:/素材/test/");
    }

    @GetMapping("/reulst")
    public Result<ResultModel> reulst() {
        ResultModel resultModel = new ResultModel();
        resultModel.setName("daddf");
        resultModel.setEstimateValue(1.2222222223);
        return Result.success(resultModel);
    }
}
